/**
* Vista asociada al contenido 
* del tab de la funcionalidad VER DOCUMENTO
* en el aplicativo.
*/
Ext.define("entgpv11.view.details.DocList", {
    extend: "Ext.Container",
    alias: "widget.doclist",
    requires: [
        //'Ext.file.File',
        'entgpv11.view.details.SourceView',
        'Ext.NestedList',
        'Ext.TitleBar'
    ],
    config: {
        fullscreen: true,
        layout: 'fit'
       
    },
    initialize: function () {
        try {
            this.callParent();
            this.listComponent = {
                xtype: 'nestedlist',
                title: 'Documentos',
                displayField: 'fileName',
             
                // add a / for folder nodes in title/back button
                getTitleTextTpl: function () {
                    return '{' + this.getDisplayField() + '}<tpl if="leaf !== true">/</tpl>';
                },
                // add a / for folder nodes in the list
                getItemTextTpl: function () {
                    return '{' + this.getDisplayField() + '}<tpl if="leaf !== true">/</tpl>';
                },
                // provide a codebox for each source file
                detailCard: new entgpv11.view.details.SourceView(),
                store: Ext.getStore("File"),
                listeners: {
                       leafitemtap: { fn: this.leafitemTapCommand, scope: this },
                       back: { fn: this.backItemCommand, scope: this }
                }
            };
           
            this.add([
            {
                xtype: 'toolbar',
                docked: 'bottom',
                ui: 'sub',
                items: [
                //TARGET="_blank"
                //onclick="openNewWindow(this.href); return false;"
                          {
                            xtype: 'panel',
                            html: '<a id="dwnldImg" href="" target="_blank" style="display: none"  ></a>'
                          },
                          { xtype: 'spacer' }

                   ]

            }, this.listComponent]);



        } catch (ex) {
            APP_GLOBAL.SetLog('DocList.initialize::' + ex);
        }
    },
    addContainerItems: function (record) {
        try {

            var customerListStore = Ext.getStore("File");
            customerListStore.setData(record);

        }
        catch (ex) {
            APP_GLOBAL.SetLog('DocList.addContainerItems::' + ex);
        }
    },
    leafitemTapCommand: function (me, list, index, item, e) {
        try 
        {
            this.fireEvent("leafitemTapCommand", me, list, index, item, e);          
            
        }
        catch (ex) {
            APP_GLOBAL.SetLog('DocList.leafitemTapCommand::' + ex);
        }
    },
    backItemCommand: function () {
        try 
        {

            this.fireEvent("backItemCommand",this);          
            
        }
        catch (ex) {
            APP_GLOBAL.SetLog('DocList.leafitemTapCommand::' + ex);
        }
    }

});

